package com.taxi.driver.common.dagger;

import android.content.Context;

import com.qianxx.utils.SP;
import com.taxi.driver.api.ApiConfig;
import com.taxi.driver.api.CommonApi;
import com.taxi.driver.api.DriverApi;
import com.taxi.driver.api.OrderApi;
import com.taxi.driver.common.retrofit.RetrofitUtil;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * 功能描述：
 */
@Module
public class AppModule {

    private Context mContext;

    public AppModule(Context context) {
        mContext = context;
    }

    @Provides
    @Singleton
    public Context provideContext() {
        return mContext;
    }

    @Provides
    @Singleton
    public SP provideSP(Context context) {
        return new SP(context);
    }

    /**
     * 获取用户信息API
     *
     * @param sp
     * @return
     */
    @Provides
    @Singleton
    public DriverApi provideDriverApi(SP sp) {
        return RetrofitUtil.getService(DriverApi.class, ApiConfig.getDriverApi(), sp);
    }

    /**
     * 获取"出租车/专车"订单API
     *
     * @param sp
     * @return
     */
    @Provides
    @Singleton
    public OrderApi provideOrderApi(SP sp) {
        return RetrofitUtil.getService(OrderApi.class, ApiConfig.getOrderApi(), sp);
    }

    /**
     * 获取司机配置接口
     *
     * @param sp
     * @return
     */
    @Provides
    @Singleton
    CommonApi provideCommonApi(SP sp) {
        return RetrofitUtil.getService(CommonApi.class, ApiConfig.getConfigUrl(), sp);
    }

//    @Provides
//    @Singleton
//    HostApi provideHostApi(SP sp) {
//        return RetrofitUtil.getService(HostApi.class, null, sp);
//    }
}
